package com.longxi.tianjintianbao.ui.activity.task_publish;

import android.content.Intent;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.longxi.tianjintianbao.R;
import com.longxi.tianjintianbao.ui.adapter.FullyGridLayoutManager;
import com.longxi.tianjintianbao.ui.base.BaseActivity;
import com.longxi.tianjintianbao.ui.presenter.task_publish.TaskPublishAtPresenter;
import com.longxi.tianjintianbao.ui.view.task_publish.ITaskPublishAtView;

import butterknife.BindView;

public class TaskPublishActivity extends BaseActivity<ITaskPublishAtView, TaskPublishAtPresenter> implements ITaskPublishAtView {
    @BindView(R.id.etContent)
    EditText mEtContent;
    @BindView(R.id.recyclerView)
    RecyclerView mRecyclerView;
    @BindView(R.id.tvAssigner)
    TextView mTvAssigner;
    @BindView(R.id.tvRequireDate)
    TextView mTvRequireDate;
    @BindView(R.id.llUrgent)
    LinearLayout mLlUrgent;
    @BindView(R.id.ivIsUrgent)
    ImageView mIvIsUrgent;
    @BindView(R.id.rvContent)
    RecyclerView mRvContent;
    @BindView(R.id.btnLogin)
    Button mBtnLogin;

    @Override
    protected int provideContentViewId() {
        return R.layout.activity_task_publish;
    }

    @Override
    public void initData() {
        super.initData();
        mPresenter.setBar();
        mPresenter.initSelectImage(getRecyclerView(), 2);
        mPresenter.initSelectPersonnel(getRvContent());
    }

    @Override
    public void initListener() {
        super.initListener();
        mTvRequireDate.setOnClickListener(v -> mPresenter.getCurrentDateTime(getTvRequireDate(), false));
        mLlUrgent.setOnClickListener(v -> mPresenter.changeIsUrgent());
        mBtnLogin.setOnClickListener(v -> mPresenter.saveTask());
    }

    @Override
    protected TaskPublishAtPresenter createPresenter() {
        return new TaskPublishAtPresenter(this);
    }

    @Override
    public EditText getEtContent() {
        return mEtContent;
    }

    @Override
    public RecyclerView getRecyclerView() {
        return mRecyclerView;
    }

    @Override
    public TextView getTvAssigner() {
        return mTvAssigner;
    }

    @Override
    public TextView getTvRequireDate() {
        return mTvRequireDate;
    }

    @Override
    public LinearLayout getLlUrgent() {
        return mLlUrgent;
    }

    @Override
    public ImageView getIvIsUrgent() {
        return mIvIsUrgent;
    }

    @Override
    public RecyclerView getRvContent() {
        return mRvContent;
    }

    @Override
    public Button getBtnLogin() {
        return mBtnLogin;
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode != RESULT_OK) {
            return;
        }
        mPresenter.onActivityResult(requestCode, resultCode, data);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
//        mPresenter.onDestroy();
    }
}


